package cn.laixueit.controller;

import cn.laixueit.pojo.Student;
import cn.laixueit.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/findAll")
    public String findAll(Model model){
        List<Student> studentList = studentService.findAll();
        model.addAttribute("studentList",studentList);
        return "list";
    }

    @GetMapping("/selectAll")
    @ResponseBody
    public List<Student> selectAll(Model model){
        List<Student> studentList = studentService.findAll();
        return studentList;
    }
}
